package de.gameduell.framework.facebook {

	import de.gameduell.framework.debug.Debug;

	public class GameResult {

		private var _resultString:String;
		private var _score:int = 0;
		private var _completed:Boolean = false;
		private var _endReason:String = "unknown";
		private var _collectedCoins:int;
		private var _taskId:String;

		public function GameResult(aResult:String, aTaskId:String){
			_resultString = aResult;
			_taskId = aTaskId;
			var results:Array = aResult.split(";");
			
			_score = int(results[0]);
			try{			
				_completed = String(results[1]) == "true";
				_endReason = String(results[2]);
				_collectedCoins = int(results[3]);
			}catch(e:Error){
				Debug.trace("GameResult::GameResult: unsupported result string ...", Debug.WARNING);
			}
		}
		
		public function get score():int {
			return _score;
		}
		
		public function get completed():Boolean {
			return _completed;
		}
		
		public function get endReason():String {
			return _endReason;
		}
		
		public function get collectedCoins():int {
			return _collectedCoins;
		}
		
		public function get taskId():String {
			return _taskId;
		}
	}
}
